package Homework;

import java.io.*;
import java.nio.charset.StandardCharsets;

public class Home {
    public static void main(String[] args) throws IOException, ClassNotFoundException {
        FileOutputStream fos = new FileOutputStream("t1.txt");
        OutputStreamWriter osw = new OutputStreamWriter(fos,StandardCharsets.UTF_8);
             osw.write("你好， 你好你好");
             osw.write(",我不太好");
             osw.close();
             System.out.println("写完了");

        FileInputStream fis = new FileInputStream("t1.txt");
        InputStreamReader isr=new InputStreamReader(fis,StandardCharsets.UTF_8);
        int i;
        while ((i=isr.read())!=-1){
            System.out.print((char) i);
        }
        System.out.println();
        System.out.println("读完了");


       // ObjectInputStream ois = new ObjectInputStream(fos);

        //InputStreamReader

        /*
        String name = "姜志可";
        int age = 24;
        String  gender = "男";
        String []arr={"天使的翅膀"};
        Student jzk=new Student(name,age,gender,arr);
        System.out.println(jzk);


        FileOutputStream fos = new FileOutputStream("x1.txt");
        ObjectOutputStream oos=new ObjectOutputStream(fos);
        oos.writeObject(jzk);
        oos.close();

        FileInputStream fis = new FileInputStream("x1.txt");
        ObjectInputStream ois = new ObjectInputStream(fis);
        Object str=ois.readObject();
        Student jk=(Student)str;

        System.out.println(jk);
        System.out.println("输出完毕");
        ois.close();

        FileInputStream fis = new FileInputStream("t1.txt");
        BufferedInputStream bis=new BufferedInputStream(fis);
        bis.read("天晴色等烟雨".getBytes(StandardCharsets.UTF_8));
        FileOutputStream fos = new FileOutputStream("x1.txt");
        BufferedOutputStream bos =new BufferedOutputStream(fos);
        System.out.println("程序已写入");
        int i;
        while ((i=bis.read())!=-1){
       bos.write(i);
        }
        System.out.println("已读");
        bos.close();
        bis.close();
       */

    }
}
